/**
 * 
 */
package com.laozhao.EasySales.control.master;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import org.apache.log4j.Logger;

import com.laozhao.EasySales.dialog.SysSqlDialog;
import com.laozhao.EasySales.view.master.SysSqlPanel;
import com.laozhao.dreamframe.util.FrameFactory;

/**
 * @author LaoZhao
 *
 */
public class SysSqlAction implements ActionListener , MouseListener{
	
	private Logger loger = Logger.getLogger(this.getClass());
	
	
	public SysSqlAction (){
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		SysSqlDialog dialog =  (SysSqlDialog) FrameFactory.getInstance(SysSqlDialog.class);
		SysSqlPanel sysSqlPanel = (SysSqlPanel) FrameFactory.getInstance(SysSqlPanel.class);
		String command = e.getActionCommand();
		loger.info(command);
		if (command.equals("Search")) {
			
		}else if (command.equals( "Add")) {
			dialog.setModelData(null);
			dialog.init();		
		}else if (command.equals( "Modify")) {
//			sysSqlPanel.
		}else if (command.equals( "Delete")) {
	
		}else if (command.equals( "Save") ){
			dialog.insertSql();
			sysSqlPanel.init();
		}else if (command.equals( "Keep")){
			dialog.insertSql();
			sysSqlPanel.init();
			dialog.setModelData(null);
			dialog.init();		
		}
			
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		SysSqlDialog dialog =  (SysSqlDialog) FrameFactory.getInstance(SysSqlDialog.class);
		SysSqlPanel sysSqlPanel = (SysSqlPanel) FrameFactory.getInstance(SysSqlPanel.class);
//		String command = e.getActionCommand();
		if (e.getClickCount() == 2) {
			dialog.setModelData(sysSqlPanel.getDataModel());
			dialog.init();	
		}
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

}
